/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

header h1 {
    text-align: center;
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 2.5em;
    font-weight: 700;
}

/* 标签页导航 */
.tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.tab-btn {
    background: linear-gradient(145deg, #f0f4f8, #d6e7f0);
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.tab-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.tab-btn.active {
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* 标签页内容 */
.tab-content {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content.active {
    display: block;
}

/* 模版管理样式 */
.template-section {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    min-height: 600px;
}

.template-list {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
}

.template-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.template-selector select {
    flex: 1;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
}

.template-info {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-size: 14px;
    line-height: 1.5;
}

.template-editor {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
}

.template-meta {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.word-count {
    display: flex;
    align-items: center;
    gap: 10px;
}

.word-count input {
    flex: 1;
}

.prompt-editors {
    display: grid;
    gap: 25px;
    margin-bottom: 25px;
}

.prompt-editor {
    background: rgba(255, 255, 255, 0.8);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.prompt-editor label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.prompt-editor textarea {
    width: 100%;
    min-height: 120px;
    height: auto;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.prompt-editor textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.template-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

/* 小说生成样式 */
.generate-section {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.single-generate,
.batch-generate {
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    padding: 20px;
    background: #f8f9fa;
}

.single-generate h2,
.batch-generate h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

/* 批量生成特有样式 */
.batch-generate {
    border-color: #e74c3c;
}

.batch-generate h2 {
    border-bottom-color: #e74c3c;
}

.generate-config {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
}

.config-group {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.config-group label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.config-group select,
.config-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    align-items: start;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    margin-bottom: 0;
    padding: 8px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.checkbox-group label:hover {
    background: rgba(102, 126, 234, 0.1);
}

.generate-content {
    display: grid;
    gap: 20px;
}

.content-section {
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.content-section h3 {
    margin-bottom: 15px;
    color: #4a5568;
    font-size: 18px;
}

#chapterOutline {
    width: 100%;
    height: 300px;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#chapterOutline:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.generate-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.status {
    font-weight: 600;
    color: #667eea;
}

.generate-result {
    display: grid;
    gap: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

#novelResult {
    width: 100%;
    height: 400px;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: 'Times New Roman', serif;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}



/* 按钮样式 */
.btn-primary {
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: linear-gradient(145deg, #f0f4f8, #d6e7f0);
    color: #4a5568;
    border: 2px solid #e2e8f0;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: linear-gradient(145deg, #e2e8f0, #cbd5e0);
    transform: translateY(-1px);
}

#newTemplateBtn {
    background: linear-gradient(145deg, #48bb78, #38a169);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#newTemplateBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
}

/* 输入框通用样式 */
input[type="text"],
input[type="number"],
select,
textarea {
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .template-section {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .generate-section {
        gap: 20px;
    }

    .generate-config {
        order: 2;
    }

    .settings-versions {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .settings-editors {
        grid-template-columns: 1fr;
        gap: 20px;
        min-height: auto;
    }

    .settings-editor {
        min-height: 300px;
    }

    .settings-section {
        margin-top: 20px;
        padding: 20px;
    }

    .checkbox-group {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        margin-bottom: 15px;
    }

    .tab-content {
        padding: 15px;
        max-width: 100%;
        margin: 0;
    }

    .tabs {
        flex-direction: column;
        gap: 5px;
    }

    .template-meta {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .template-actions,
    .result-actions {
        flex-direction: column;
        gap: 10px;
    }

    .generate-section {
        gap: 15px;
    }

    .single-generate,
    .batch-generate {
        padding: 15px;
    }

    .batch-actions {
        flex-direction: column;
        gap: 10px;
    }

    .batch-actions .status {
        min-width: auto;
        width: 100%;
    }

    .novel-id-group {
        flex-direction: column;
        align-items: stretch;
    }

    .novel-id-group input {
        margin-bottom: 8px;
    }

    .version-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .version-group label {
        min-width: auto;
    }

    .checkbox-group {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .single-generate .generate-config,
    .batch-generate .batch-config {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* 加载动画 */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* 小说ID组件样式 */
.novel-id-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.novel-id-group input {
    flex: 1;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-width: 60px;
}

.btn-small:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.novel-info {
    margin-top: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
    display: none;
}

.novel-info.show {
    display: block;
}

.novel-info.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.novel-info.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.novel-info.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* 记忆设置帮助文本 */
.memory-help {
    margin-top: 12px;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.memory-help small {
    color: #6c757d;
    line-height: 1.4;
}

/* 按钮样式 */
.btn-danger {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
    transform: translateY(-1px);
}

.btn-danger:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

/* 进度条样式 */
.progress-bar {
    width: 100%;
    height: 20px;
    background: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
    border: 1px solid #bdc3c7;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.progress-text {
    text-align: center;
    font-weight: bold;
    color: #2c3e50;
    margin: 10px 0;
}

/* 批量日志样式 */
.batch-log {
    max-height: 300px;
    overflow-y: auto;
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    margin-top: 15px;
    border: 1px solid #34495e;
}

.batch-log:empty {
    display: none;
}

.log-entry {
    margin: 5px 0;
    padding: 3px 0;
}

.log-success {
    color: #2ecc71;
}

.log-error {
    color: #e74c3c;
}

.log-info {
    color: #3498db;
}

.log-warning {
    color: #f39c12;
}

/* 批量操作按钮组 */
.batch-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    margin: 20px 0;
    flex-wrap: wrap;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.batch-actions .status {
    flex: 1;
    min-width: 200px;
    font-size: 14px;
    font-weight: 500;
    color: #4a5568;
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(245, 245, 245, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.batch-actions .status.info {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #1e40af;
}

.batch-actions .status.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.batch-actions .status.success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #16a34a;
}

.batch-actions .status.warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: #d97706;
}

/* 单章生成布局 */
.single-generate .generate-config,
.batch-generate .batch-config {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
    margin-bottom: 25px;
}

.single-generate .generate-content {
    width: 100%;
}

/* 设定管理区样式 */
.settings-section {
    background: white;
    border-radius: 12px;
    border: 2px solid #f39c12;
    padding: 25px;
    margin-top: 30px;
    box-shadow: 0 4px 20px rgba(243, 156, 18, 0.1);
    width: 100%;
    grid-column: 1 / -1;
    /* 占满整行，不受父级grid布局影响 */
}

.settings-section h2 {
    color: #f39c12;
    border-bottom: 2px solid #f39c12;
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 24px;
}

.settings-config {
    background: #fefefe;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #e1e5e9;
    width: 100%;
}

.settings-versions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-top: 20px;
    align-items: center;
}

.version-group {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(243, 156, 18, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(243, 156, 18, 0.2);
}

.version-group label {
    font-weight: 600;
    color: #4a5568;
    min-width: 120px;
}

.version-group select {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
}

.settings-editors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px;
    align-items: stretch;
    min-height: 800px;
    width: 100%;
}

.settings-editor {
    background: #fefefe;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #e1e5e9;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.settings-editor label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 10px;
    font-size: 16px;
}

.settings-editor textarea {
    width: 100%;
    min-height: 200px;
    height: auto;
    flex: 1;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: 15px;
    transition: border-color 0.3s ease;
    overflow-y: auto;
    box-sizing: border-box;
}

.settings-editor textarea:focus {
    outline: none;
    border-color: #f39c12;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1);
}

.settings-editor button {
    width: 100%;
    margin-top: auto;
}

@media (max-width: 1200px) {
    .settings-versions {
        grid-template-columns: 1fr;
    }

    .settings-editors {
        grid-template-columns: 1fr;
    }
}